Passing parameter of video filename to flash player

43 views
Skip to first unread message

Harry Hooper

unread,
Aug 4, 2010, 1:31:15 PM8/4/10
to SWFObject
I am able to post flash videos to my website as long as I can hard
code the video filename into the <object> code. Like this:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version=7,0,0,0" width="800" height="450" id="player1"
align="middle">
<param name="movie" value="passing.swf"/>
<param name="menu" value="false"/>
<param name="quality" value="high"/>
<param name="bgcolor" value="#FFFFFF"/>
<noscript><a href="http://www.dvdvideosoft.com/products/dvd/Free-
YouTube-Download.htm">youtube video</a></noscript>
<embed src="passing.swf" menu="false" quality="high" bgcolor="#FFFFFF"
width="800" height="450" name="player" align="middle"
allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer"/>
</object>

I have a page that allows the video to be selected from a list that is
populated from an Access database. I want the page to then call a
generic flash page with an HTML parm of filename and have the single
page display all the videos from my site. The parm is being passed and
received but I can't get the flash player pick it up and play it. The
value passed is being received in a variable named "video". I have
tried:

<param name="movie" value="passing.swf?video"/>
<param name="movie" value=<%=video %>/>
<param name="movie" value=Request.QueryString("video")/>

etc. All with no success. I do understand that I need to put it in
both the param line and also the embed line so that's not the problem.
I have googled this subject and found several references to the <param
name="movie" value="passing.swf?video"/> method but they were all very
vague as to the method of reading the command line parm and
transfering it to the param line.

Thanx in advance for any help.

Aran Rhee

unread,
Aug 7, 2010, 2:55:11 PM8/7/10
to swfo...@googlegroups.com
First of all, you are not using SWFObject on your page / code example. I will assume you do actually want to use 


Have a brief (re)read of the documentation.

If you want to pass data to the swf, then generally you want to use the flashvars param. Below is a full code example (assuming that <%=video%> does actually contain the string you are expecting)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("player1", "7.0.0");
</script>
</head>
<body>
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="450" id="player1">
<param name="movie" value="passing.swf" />
<param name="flashvars" value="video=<%=video%>" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="passing.swf" width="800" height="450">
<param name="flashvars" value="video=<%=video%>" />
<!--<![endif]-->
alt content here
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
</body>
</html>




I suggest in future, you check out the swfobject generator. It helps you make sure your code is all correct and ready to go:



Aran



--
You received this message because you are subscribed to the Google Groups "SWFObject" group.
To post to this group, send email to swfo...@googlegroups.com.
To unsubscribe from this group, send email to swfobject+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/swfobject?hl=en.


Harry Hooper

unread,
Aug 7, 2010, 3:35:58 PM8/7/10
to SWFObject
Tried that - got this error:

Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.

Compiler Error Message: BC30451: Name 'video' is not declared.

Source Error:

Line 13: <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
width="800" height="450" id="player1">
Line 14: <param name="movie" value="passing.swf" />
Line 15: <param name="flashvars" value="video=<%=video%>" />
Line 16: <!--[if !IE]>--
Line 17: <object type="application/x-shockwave-flash"
data="passing.swf" width="800" height="450">

> <http://code.google.com/p/swfobject/wiki/generator>
> > swfobject+...@googlegroups.com<swfobject%2Bunsu...@googlegroups.com>
> > .

Aran Rhee

unread,
Aug 10, 2010, 9:19:30 AM8/10/10
to swfo...@googlegroups.com
Well, that is not a client-side error, so there must be something in your asp code....

have you declared <%=video%> with a value somewhere?

Aran

To unsubscribe from this group, send email to swfobject+...@googlegroups.com.

Harry Hooper

unread,
Aug 10, 2010, 4:37:31 PM8/10/10
to SWFObject
This is the code above the <object> code

<%
dim video
video = request("video")
response.write(video)
%>

The response.write indicates that the correct parm is being read.

I'm a newbie at this flash code but it seems that there might be a way
to somehow declare a variable in the flash code. I have no way of
doing that. I create a flash move from a MP4 movie with a free
converter I found.

I'm at my wit's end trying to figure this out. It seems like it
should be so simple but I can't get it to work. I think I'm
overlooking some simple thing.

Thanx
Harry



On Aug 10, 8:19 am, Aran Rhee <aran.r...@gmail.com> wrote:
> Well, that is not a client-side error, so there must be something in your
> asp code....
>
> have you declared <%=video%> with a value somewhere?
>
> Aran
>
> > <swfobject%2Bunsu...@googlegroups.com<swfobject%252Buns...@googlegroups.com>

Aran Rhee

unread,
Aug 10, 2010, 4:47:59 PM8/10/10
to swfo...@googlegroups.com
Ok, so can we verify that the variable value is available in js?

<%
dim video
video = request("video")
%>

<script language=javascript>
   var jVideo = "<%= video%>";
   alert(jVideo);
</script>

Once we know everything is happy in js land, then we can remove asp as part of the issue.

Just to confirm, your passing.swf IS setup to handle the video varialbe and will do what it needs to with the string to laod and display the video file, yes?

BTW - if you are just passing the video variable in the querystring, the swfobject already has a util function to grab the variable etc:

flashvars.foo = swfobject.getQueryParamValue("foo");

Aran

To unsubscribe from this group, send email to swfobject+...@googlegroups.com.

Harry Hooper

unread,
Aug 10, 2010, 5:22:19 PM8/10/10
to SWFObject
I don't have a "passing.swf". That was just something I copied from
some code I found. All I have is several video files (swf) that I
converted from MP4s.

How do I get a "passing.swf" and set it up to handle the video
variable?

flashvars.foo = swfobject.getQueryParamValue("foo");. I have seen
this code but I didn't understand the "foo" part of it.

I'm a newbie at flash and would appreciate any help and code you could
provide. Most of the material I've been reading assumes I know a lot
more about it than I do.

Thanx
H@rry



On Aug 10, 3:47 pm, Aran Rhee <aran.r...@gmail.com> wrote:
> Ok, so can we verify that the variable value is available in js?
>
> <%
> dim video
> video = request("video")
> %>
>
> <script language=javascript>
>    var jVideo = "<%= video%>";
>    alert(jVideo);
> </script>
>
> Once we know everything is happy in js land, then we can remove asp as part
> of the issue.
>
> Just to confirm, your passing.swf IS setup to handle the video varialbe and
> will do what it needs to with the string to laod and display the video file,
> yes?
>
> BTW - if you are just passing the video variable in the querystring, the
> swfobject already has a util function to grab the variable etc:
>
> flashvars.foo = swfobject.getQueryParamValue("foo");
>
> http://code.google.com/p/swfobject/wiki/api
>
> Aran
>
> > > > <swfobject%2Bunsu...@googlegroups.com<swfobject%252Buns...@googlegroups.com>
> > <swfobject%252Buns...@googlegroups.com<swfobject%25252Bun...@googlegroups.com>

Aran Rhee

unread,
Aug 10, 2010, 5:50:20 PM8/10/10
to swfo...@googlegroups.com
Harry.

Not having a swf to handle the reading or playback of the video file location - That would have been something nice to know from your first post... In future, please explain the situation fully (you'll save yourself and anyone responding a bunch of time and frustration)

Coding a video player .swf to handle flashvars etc is outside of the scope of this list. I can suggest a couple of things:

1) Go and grab one of the open source video players like flowplayer or jw mediaplayer. They are already setup to handle the flashvars, playback of mp4 videos etc. This means you don't have to code the player from scratch and you can jsut customise the look and feel
2) Ask some questions on genraliss flash forums like kirupa.com or actionscript.org


BTW - 
"foo" (and "bar") are example variables which are used in teaching/examples to to show how to implement something (but not to confuse the reader that it is the real variable to be used). These are not terms just for Flash, so I am guessing you are pretty new to programming full stop.I appreciate learning development skills can have a learning curve, but you might want to do some further reading/ follow some tuts on general javascript and Flash development so that you have some basic concepts under your belt.

Aran
 


To unsubscribe from this group, send email to swfobject+...@googlegroups.com.

Harry Hooper

unread,
Aug 10, 2010, 7:32:30 PM8/10/10
to SWFObject
Aran;

Please allow me to apologize for not stating that I didn't have the
proper swf file initially, but I did't know about it. Sorry.

Thank you for the info on flowplayer and jw mediaplayer. I'll take a
look at them. That will probably be what I need.

Actually, I'm new to Flash programming but not new to programming.
I'm a retired AS400/RPG programmer who got started on web programming
in '04.

Again, allow me to apologize for my ignorance and thank you for taking
the time to point me in the right direction. I'll take a look there
and when I come back I'll have a better handle on this.

Thanx
H@rry

On Aug 10, 4:50 pm, Aran Rhee <aran.r...@gmail.com> wrote:
> Harry.
>
> Not having a swf to handle the reading or playback of the video file
> location - That would have been something nice to know from your first
> post... In future, please explain the situation fully (you'll save yourself
> and anyone responding a bunch of time and frustration)
>
> Coding a video player .swf to handle flashvars etc is outside of the scope
> of this list. I can suggest a couple of things:
>
> 1) Go and grab one of the open source video players like flowplayer or jw
> mediaplayer. They are already setup to handle the flashvars, playback of mp4
> videos etc. This means you don't have to code the player from scratch and
> you can jsut customise the look and feel
> 2) Ask some questions on genraliss flash forums like kirupa.com or
> actionscript.org
>
> BTW -
> "foo" (and "bar") are example variables which are used in teaching/examples
> to to show how to implement something (but not to confuse the reader that it
> is the real variable to be used). These are not terms just for Flash, so I
> am guessing you are pretty new to programming full stop.I appreciate
> learning development skills can have a learning curve, but you might want to
> do some further reading/ follow some tuts on general javascript and
> Flash development so that you have some basic concepts under your belt.
>
> Aran
>
> ...
>
> read more »

Aran Rhee

unread,
Aug 10, 2010, 10:08:37 PM8/10/10
to swfo...@googlegroups.com
Hey Harry.

I wasn't meaning to berate (or discourage) you, just a pointer for next time you need some help so that everyone involved can come to the solution as quickly as possible :). As you would know from any programming problem, when you can't limit the scope of the issue and know all the moving parts, it is very hard to get to the root cause.

Either Flow player or JW media player are a great resource for people who don't yet have the skills (or perhaps the time) to write a player from scratch.They both have a nice js api you cal call from your html page to control everything from the file(s) to play, to the look and feel of the player.

Let me apologize for making the assumption that you had no programming experience. I thought pretty much every programmer had been exposed to foobar at some stage of looking at example code. Obviously this is not the case (even though they have been in common usage since the 60's - http://en.wikipedia.org/wiki/Foobar )

Anyhow, once you chose a player swf, and you know what parameters you need to pass to it, use the swfobject generator to help you format the code correctly. 

There is also a good tutorial style site on swfobject which goes into vaariuous real world exmaples here: http://learnswfobject.com/


Cheers,
Aran


Reply all
Reply to author
Forward
0 new messages